<?php

use yii\helpers\Html;
use yii\widgets\DetailView;
use yii\widgets\LinkPager;
use yii\helpers\Url;
$this->params['breadcrumbs'][] = $this->title;

?>
  <div class="weui_tab index">

    <div class="weui_tab_bd" >

      <div class="weui_tab_bd_item weui_tab_bd_item_active" id="tab1">

        <div class="top content-pad">
          <img src="http://static.tianpinwang.com.cn/v1/images/logo.png" alt="" class="logo">
          <img src="http://static.tianpinwang.com.cn/v1/mobile/images/slogen.png" alt="" class="right">
        </div>
        <div class="weui_search_bar" id="search_bar">
          <form class="weui_search_outer" action="/product" method="get" onsubmit="return checkform();">
            <div class="weui_search_inner">
              <i class="weui_icon_search"></i>
              <input type="search" name="name" class="weui_search_input" id="search_input" placeholder="搜索">
              <a href="javascript:" class="weui_icon_clear" id="search_clear"></a>
            </div>
            <label for="search_input" class="weui_search_text" id="search_text">
              <i class="weui_icon_search"></i>
              <span>搜索</span>
            </label>
          </form>
          <div class="searchBtn"><i class="weui_icon_search"></i></div>
        </div>

        <div class="swiper-container" data-space-between='10' data-pagination='.swiper-pagination' data-autoplay="1000">
          <div class="swiper-wrapper">

            <?php foreach ($banner as $key => $value): ?>
              <div class="swiper-slide">
                <img src="<?=Html::encode($value['img_url']) ?>" alt="<?=Html::encode($value['name']) ?>">
              </div>
            <?php endforeach ?>

          </div>
          <div class="swiper-pagination"></div>
        </div>

        <div class="bannerSub">

          <a href="/product?lv1=72">
            <dl>
              <dt class="fir">
                <img src="http://static.tianpinwang.com.cn/v1/mobile/images/banSubIcon2.png" alt="">
              </dt>
              <dd>食品添加剂</dd>
            </dl>
          </a>
          <a href="/product?lv1=95">
            <dl>
              <dt class="sec">
                <img src="http://static.tianpinwang.com.cn/v1/mobile/images/banSubIcon3.png" alt="">
              </dt>
              <dd>食品配料</dd>
            </dl>
          </a>
          <a href="/product?lv1=96">
            <dl>
              <dt class="thi">
                <img src="http://static.tianpinwang.com.cn/v1/mobile/images/banSubIcon1.png" alt="">
              </dt>
              <dd>食品调味料</dd>
            </dl>
          </a>

        </div>

        <div class="weui_cells goodsList">
          <div class="weui_cells_title goodListTt">热门商品</div>

          <?php foreach ($pro_list as $key => $value): ?>
            <a class="weui_cell" href="/product/<?=Html::encode($value['id'])?>">
              <div class="weui_cell_hd">
                <img src="<?=Html::encode($value['img_url'])?>" alt="" class="goodsImge">
              </div>
              <div class="weui_cell_bd weui_cell_primary">
                <p class="goodsName"><?=Html::encode($value['name'])?></p>
                <p class="infoTxt2">
                  <span class="area"><?=Html::encode($value['bname'])?></span>
                  <span class="right">已售<?=Html::encode($value['sale_sum']?$value['sale_sum']:'0')?><?=Html::encode($value['price_unit'])?></span>
                </p>
                <p class="infoTxt3">
                  <span class="price">￥<?=Html::encode($value['product_price'])?>/<?= Html::encode($value['price_unit'])?></span>
                  <span class="right lowCount"></span>
                </p>
              </div>
            </a>
          <?php endforeach ?>

        </div>

      <!--滚动容器内的要加的加载提示-->
      <div class="weui-infinite-scroll" id="tips" style="display:none;">
        <div class="infinite-preloader"></div><!-- 菊花 -->
        正在加载... <!-- 文案，可以自行修改 -->
      </div>

      </div>
      <div class="weui_tab_bd_item" id="tab2" style="height: 3000px;">2222</div>
      <div class="weui_tab_bd_item" id="tab3">3333</div>


    </div>

    <div class="weui_tabbar">
      <a href="/" class="weui_tabbar_item weui_bar_item_on">
        <div class="weui_tabbar_icon">
          <img src="http://static.tianpinwang.com.cn/v1/mobile/images/shouye.png" alt="" class="notCur">
          <img src="http://static.tianpinwang.com.cn/v1/mobile/images/shouye_cur.png" alt="" class="current">
        </div>
        <p class="weui_tabbar_label">首页</p>
      </a>
      <a href="/category" class="weui_tabbar_item">
        <div class="weui_tabbar_icon">
          <img src="http://static.tianpinwang.com.cn/v1/mobile/images/fenlei.png" alt=""  class="notCur">
          <img src="http://static.tianpinwang.com.cn/v1/mobile/images/fenlei_cur.png" alt="" class="current">
        </div>
        <p class="weui_tabbar_label">分类</p>
      </a>
      <a href="/index/about#aboutTab26" class="weui_tabbar_item">
        <div class="weui_tabbar_icon">
          <img src="http://static.tianpinwang.com.cn/v1/mobile/images/guanyu.png" alt=""  class="notCur">
          <img src="http://static.tianpinwang.com.cn/v1/mobile/images/guanyu_cur.png" alt="" class="current">
        </div>
        <p class="weui_tabbar_label">关于添品网</p>
      </a>
    </div>

  </div>



  <div class="fixedTel" style=""></div>
  <div class="fixedTotop"></div>

<script>
  $(function(){

    var $height=$(window).height();
    $(".swiper-container").swiper({
      loop: true,
      autoplay: 6000
    })

  });

  $('.index .weui_tab_bd').css('height',$(window).height());

  $('<div>',{
    'style': 'width: 40px;height: 40px;-webkit-border-radius: 50%;-moz-border-radius: 50%;border-radius: 50%;background: rgba(0,0,0,0.7);'+
    'position: fixed;bottom: 120px;right: 15px;text-align: center',
    'id': 'fixPhone'
  }).html('<a href="tel:<?= $this->params['w_config']['contact_tel'] ?>"><img src="http://static.tianpinwang.com.cn/v1/mobile/images/fixedTel.png" style="margin-top: 6px;width: 68%;"/></a>').appendTo("body");

  $('<div>',{
    'style': 'width: 40px;height: 40px;-webkit-border-radius: 50%;-moz-border-radius: 50%;border-radius: 50%;background: rgba(0,0,0,0.7);'+
    'position: fixed;bottom: 60px;right: 15px;text-align: center',
    'id': 'fixTotop'
  }).html('<img src="http://static.tianpinwang.com.cn/v1/mobile/images/fixedTotop.png" style="margin-top: 8px;width: 38%;"/>').appendTo("body");

  $('#fixTotop').click(function(){
    $('.weui_tab_bd_item.weui_tab_bd_item_active').animate({scrollTop: 0},100);
  })
</script>

<script>
  $(function(){
    var loading = false;  //状态标记
    $('#tab1').infinite().on("infinite", function() {
      if(loading) return;
      $('#tips').attr('style','display:block');
      loading = true;
      var off = $('.goodsList').attr('value');
      if(!off){
        off = 1;
      }
      $.post('/',{'offset':off},function(data){
        var data = eval('('+data+')');
        setTimeout(function() {
          var cont = '';
          if(data[0]){
            for (var i = 0; i < data.length; i++) {
              cont += '<a class="weui_cell" href="/product/'+data[i]["id"]+'"><div class="weui_cell_hd"><img src="'+data[i]["img_url"]+'" alt="" class="goodsImge"></div><div class="weui_cell_bd weui_cell_primary"><p class="goodsName">'+data[i]["name"]+'</p><p class="infoTxt2"><span class="area">'+data[i]['bname']+'</span><span class="right">已售'+data[i]["sale_sum"]+data[i]["price_unit"]+'</span></p><p class="infoTxt3"><span class="price">￥'+data[i]["product_price"]+'/'+data[i]["price_unit"]+'</span><span class="right lowCount"></span></p></div></a>';
            }
            $('.goodsList').attr('value',parseInt(off)+1);
            $(".goodsList").append(cont);
            loading = false;
            $('#tips').attr('style','display:none');
          }else{
            loading = false;
            $('#tips').text('没有更多了~');
          }
        }, 500);   //模拟延迟
      });
    });
  })
</script>